import { Component, ViewChild, Injector, Output, EventEmitter } from '@angular/core';
import { ModalDirective } from 'ngx-bootstrap';
import { TechRuleServiceProxy, TechRuleListDto} from '@shared/service-proxies/service-proxies';
import { AppComponentBase } from '@shared/common/app-component-base';

import { Table } from 'primeng/table';
import { Paginator } from 'primeng/primeng';

@Component({
  selector: 'editOutOrBackTechRuleModal',
  templateUrl: './edit-out-or-back-techrule-modal.component.html'
})

export class EditOutOrBackTechRuleModalComponent extends AppComponentBase {

  @ViewChild('editModal') modal: ModalDirective;
  @ViewChild('dataTable') dataTable: Table;
  @ViewChild('paginator') paginator: Paginator;

  @Output() modalSave: EventEmitter<any> = new EventEmitter<any>();

  active = false;
  saving = false;

  operationNames = ['', '借出/配备', '返修', '送检', '技改', '报废'];// '隔离',

  stockInfo = '';
  remark = '';

  operation = 0;
  type = 0; // 出库 1 入库 2 第一次入库 3
  techrule = new TechRuleListDto();

  constructor(
    injector: Injector,
    private _techruleService: TechRuleServiceProxy
  ) {
    super(injector);
  }

  show(techrule: TechRuleListDto, operation: number, type: number): void {
    this.active = true;

    this.operation = operation;
    this.type = type;

    this.techrule = techrule;

    // 初始化 信息
    this.stockInfo = '';
    this.remark = '';

    this.modal.show();

  }

  save(): void {
    this.saving = true;

  }

  close(): void {
    this.active = false;
    this.modal.hide();
  }
}
